package cn.huobi.org.eum;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum ShopStateEum {
    WAIT_AUDIT(0,"待审核"),
    HAVE_AUDIT(1,"已审核"),
    REJECT(-1,"驳回"),
    PASS(2,"已激活");

    private int code;
    private String name;

    public static  String getNameByCode(Integer code){
        ShopStateEum[] values = ShopStateEum.values();
        ShopStateEum stateEum = Arrays.stream(values).filter(state -> state.getCode() == code).findAny().orElse(null);
        return null == stateEum ? "" : stateEum.getName();
        // 等同于
//        for (ShopStateEum state : values) {
//            if (state.getCode() == code){
//                return state.getName();
//            }
//            return "";
//        }
    }
}
